# -*- coding:utf-8 -*-


from django.db import models

from Apps.common.custommodel import CustomModel
from Apps.user.models import User


class Params(CustomModel):
    enable = models.CharField(null=True, blank=True, max_length=1, default='1',
                              verbose_name='是否启用(0-未启用，1-启用)')
    required = models.CharField(null=True, blank=True, max_length=1, default='1',
                                verbose_name='是否必填(0-不必填，1-必填)')
    param_name = models.CharField(max_length=30, default="", verbose_name="param参数名")
    param_value = models.CharField(max_length=30, default="", verbose_name="param参数值（默认值，或者mock数据，变量）")
    param_more = models.TextField(default='', verbose_name='参数值更多筛选设置')
    data_type = models.CharField(max_length=30, default="", verbose_name="类型(integer string ...)")
    param_description = models.CharField(max_length=50, default="", verbose_name="param描述")

    creator = models.ForeignKey(User, on_delete=models.DO_NOTHING, default="",
                                related_name="user_param_c",
                                verbose_name="创建人")
    modifier = models.ForeignKey(User, on_delete=models.DO_NOTHING, default="",
                                 related_name="user_param_m",
                                 verbose_name="修改人")

    class Meta:
        db_table = "interface_param"
        verbose_name = "query字段表"

    def __str__(self):
        return self.param_name
